package cn.sunshine.comprehensive.observer_mediator;

/**
 * @Description cn.sunshine.comprehensive.observer_mediator
 * @Author Mokairui
 * @Since 2021/12/30
 */
public class Client {

    public static void main(String[] args) {
        DefaultMediatorStructure mediatorStructure = new DefaultMediatorStructure();

//        QQUser qqUser = new QQUser(mediatorStructure, "QQ用户");
//        WeixinUser weixinUser = new WeixinUser(mediatorStructure, "微信用户");

        QQUser qqUser = new QQUser("QQ用户");
        WeixinUser weixinUser = new WeixinUser("微信用户");

        // 将中介者聚合到通信对象的操作转移到了中介者的添加对象的方法中
        mediatorStructure.attach(qqUser);
        mediatorStructure.attach(weixinUser);

        qqUser.contact("唉, 一天又过去了");
        System.out.println("----------------------");
        weixinUser.contact("是啊, 一天过得真快, 今天学到了什么呀?");
    }

}
